﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CustomsSystem.BLL;
using Maticsoft.Common;

namespace WEB.Form
{
    public partial class FormView : System.Web.UI.Page
    {
        info_formMaster fmbll = new info_formMaster();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gv_fm.DataSource = fmbll.GetList("").Tables[0];
                gv_fm.DataBind();
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Del_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt16(((Button)sender).CommandArgument);
            if (fmbll.Delete(id))
            {
                MessageBox.ShowAndRedirect(this, "删除成功！","./FormView.aspx");
            }
            else
            {
                MessageBox.Show(this, "删除失败！");
            }
        }
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void bt_Add_Click(object sender, EventArgs e)
        {
            Response.Redirect("./FormEdit.aspx");
        }

        protected void gv_fm_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "edit")//修改
            {
                string id = gv_fm.Rows[Convert.ToInt32(e.CommandArgument)].Cells[2].Text;
                Response.Redirect("./FormEdit.aspx?ID=" + id);
            }
        }

    }
}